﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace fanfu.Common
{
    /// <summary>
    /// URL编码/解码类
    /// </summary>
    public sealed class URL
    {
        /// <summary>
        /// URL地址编码(HttpServerUtility.URLEncode方法进行编码)
        /// </summary>
        /// <param name="Input"></param>
        /// <returns></returns>
        public static string Encode(string Input)
        {
            return HttpContext.Current.Server.UrlEncode(Input);
        }

        /// <summary>
        /// URL地址解码(HttpServerUtility.URLEncode方法进行解码)
        /// </summary>
        /// <param name="Input"></param>
        /// <returns></returns>
        public static string Decode(string Input)
        {
            return HttpContext.Current.Server.UrlDecode(Input);
        }

        /// <summary>
        /// 用HttpUtility.UrlEncode方法对URL进行编码
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string URLEncode(string str)
        {
            return HttpUtility.UrlEncode(str);
        }

        /// <summary>
        /// 用HttpUtility.UrlEncode方法对URL进行解码
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string URLDecode(string str)
        {
            return HttpUtility.UrlDecode(str);
        }
    }
}
